#pragma once
#include <Aspect_Window.hxx>
#include <Standard_WarningsDisable.hxx>
#include <QWidget>
#include <Standard_WarningsRestore.hxx>

class OcctWindow : public Aspect_Window
{
    DEFINE_STANDARD_RTTIEXT(OcctWindow,Aspect_Window)
public:

    //! Constructor
    OcctWindow( QWidget* theWidget, const Quantity_NameOfColor theBackColor = Quantity_NOC_MATRAGRAY );

    //! Destructor
    virtual ~OcctWindow()
    {
        myWidget = NULL;
    }

    //! Returns native Window handle
    virtual Aspect_Drawable NativeHandle() const Standard_OVERRIDE
    {
        return (Aspect_Drawable)myWidget->winId();
    }

    //! Returns parent of native Window handle.
    virtual Aspect_Drawable NativeParentHandle() const Standard_OVERRIDE;

    //! Applies the resizing to the window <me>
    virtual Aspect_TypeOfResize DoResize() Standard_OVERRIDE;

    //! Returns True if the window <me> is opened
    //! and False if the window is closed.
    virtual Standard_Boolean IsMapped() const Standard_OVERRIDE
    {
        return !(myWidget->isMinimized() || myWidget->isHidden());
    }

    //! Apply the mapping change to the window <me>
    //! and returns TRUE if the window is mapped at screen.
    virtual Standard_Boolean DoMapping() const Standard_OVERRIDE { return Standard_True; }

    //! Opens the window <me>.
    virtual void Map() const Standard_OVERRIDE;

    //! Closes the window <me>.
    virtual void Unmap() const Standard_OVERRIDE;

    virtual void Position( Standard_Integer& theX1, Standard_Integer& theY1,
                          Standard_Integer& theX2, Standard_Integer& theY2 ) const Standard_OVERRIDE;

    //! Returns The Window RATIO equal to the physical
    //! WIDTH/HEIGHT dimensions.
    virtual Standard_Real Ratio() const Standard_OVERRIDE;

    virtual void Size( Standard_Integer& theWidth, Standard_Integer& theHeight ) const Standard_OVERRIDE;

    virtual Aspect_FBConfig NativeFBConfig() const Standard_OVERRIDE { return NULL; }

protected:
    Standard_Integer myXLeft;
    Standard_Integer myYTop;
    Standard_Integer myXRight;
    Standard_Integer myYBottom;
    QWidget* myWidget;
};
